package com.zj;

import com.zj.bean.DemoBean;
import com.zj.filter.TpMonitorFilter;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.concurrent.*;

public class ConsumerMain {
    public static void main(String[] args)throws  Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        DemoBean bean = context.getBean(DemoBean.class);

        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2000);
        //scheduledExecutorService.scheduleAtFixedRate(()->TpMonitorFilter.report(),20,20, TimeUnit.SECONDS);
        while (true){
            scheduledExecutorService.submit(()-> bean.methodA());
            scheduledExecutorService.submit(()-> bean.methodB());
            scheduledExecutorService.submit(()-> bean.methodC());
            Thread.sleep(25);
        }

    }
    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan(basePackages = "com.zj.bean")
    @EnableDubbo
    static  class  ConsumerConfiguration{

    }
}
